<template>
	<view class="test-account">
		<view class="account-item" v-for="item in accounts">
			<uv-button type="primary" :text="item.userName" @click="loginTest(item)"></uv-button>
		</view>

	</view>
</template>

<script setup>
	import api from './api';
	const accounts = [{
		userName: 'test1',
		password: '123456'
	}, {
		userName: 'test2',
		password: '123456'
	}, {
		userName: 'test3',
		password: '123456'
	}, {
		userName: 'test4',
		password: '123456'
	}, {
		userName: 'test5',
		password: '123456'
	}, {
		userName: 'test6',
		password: '123456'
	}, {
		userName: 'test7',
		password: '123456'
	}, {
		userName: 'test8',
		password: '123456'
	}, {
		userName: 'test9',
		password: '123456'
	}]
	import {
		useUserStore
	} from '@/stores/user';
	const userStore = useUserStore()
	import { useTabbarStore } from '@/stores/tabbarer'
	const tabbarStore = useTabbarStore()
	const loginTest = (item)=>{
		api.loginByTest(item).then(res=>{
			console.log(res);
			if (res.successed) {
				userStore.token = res.token
				api.getInfo().then(res => {
					console.log(res.data);
					userStore.avatar = res.data.avatar
					userStore.nickName = res.data.nickName
					userStore.userId = res.data.id
					api.getFollowers().then(flo=>{
						flo.datas.forEach(item=>{
							userStore.followers.push(item.followerId)
						})
					})
				})
				useTabbarStore.tabIndex = 2
				uni.switchTab({
					url:'/pages/person/index'
				})
			}
		})
	}
</script>

<style lang="scss">
	.test-account{
		.account-item{
			    margin: 20rpx auto;
			    width: 60%;
		}
	}
</style>